<?php
// Edit profile page
//
// digiboard by digitalboom.org
// http://www.digitalboom.org
//
// Information Technology program
// Sirindhorn International Institute of Technology
// Thammasat University, Rangsit Campus
// http://www.siit.tu.ac.th
//
// authors: seniors?, sea
// first created on: 2002 May 07
// last modified on: 2008 May 14
// last modified by: sea

include("settings/config.inc.php");
include("settings/accounts.inc.php");
include("lib/util.inc.php");

extract($_POST);
extract($_GET);

// select user profile from DB
$db_link = dgb_db_connect();
$query = "SELECT * FROM ".$DGB["DB_USERS_TABLE"]." WHERE Username = '$_COOKIE[Username]' and Password ='".md5($_COOKIE[Password])."' ";
$result = mysql_query($query,$db_link);
$data = mysql_fetch_row($result);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>my profile</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$DGB["ENCODING"];?>">
<link rel="stylesheet" href="<?=$DGB["STYLESHEET"];?>" type="text/css">
</head>

<body bgcolor="#FFFFEE" >
<table width="100%" border=0 cellspacing=1 cellpadding=1 align="center">
 <tr> 
  <td class="pHead" align="center"> 
   <?=$DGB["WEBBOARD_NAME"];?> / my profile
  </td>
 </tr>
 <tr> 
  <td class="pSubHead" align="center"> 
   <font color="#FFFFFF"><b>Edit your profile below</b></font>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <tr>
  <td>
   <form name="form1" method="post" action="editprofile.php">
    <table width=500 border=0 cellspacing=0 cellpadding=1 align="center" bgcolor="#996699">
     <tr>
      <td valign="top">
       <table width=500 border=0 cellspacing=0 cellpadding=1 align="center">
        <tr> 
         <td colspan=3 class="pHead">Your profile details</td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td width=10>&nbsp;</td>
         <td width=200>Username </td>
         <td width=290><?=$_COOKIE[Username];?></td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td><font color="#FF0000">*</font></td>
         <td>E-mail</td>
         <td>
          <input type="text" name="Email" size=20 maxlength=255 value="<?=$data[3];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>ICQ</td>
         <td> 
          <input type="text" name="ICQ" size=20 maxlength=50 value="<?=$data[4];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>MSN</td>
         <td> 
          <input type="text" name="MSN" size=20 maxlength=50 value="<?=$data[5];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Website</td>
         <td> 
          <input type="text" name="Website" size=20 maxlength=255 value="<?=$data[6];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td colspan=3>&nbsp;</td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Name</td>
         <td> 
          <input type="text" name="Name" size=20 maxlength=255 value="<?=$data[7];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Lastname</td>
         <td> 
          <input type="text" name="Lastname" size=20 maxlength=255 value="<?=$data[8];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Nickname</td>
         <td> 
          <input type="text" name="Nickname" size=20 maxlength=255 value="<?=$data[9];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Birthdate</td>
         <td> 
          <input type="text" name="Birthdate"  size=15 value="<?=$data[14];?>">
          ex. 20/01/1970
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Address </td>
         <td> 
          <textarea name="Address" cols=30 rows=4><?=$data[15];?></textarea>
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Telephone</td>
         <td> 
          <input type="text" name="Telephone" size=20 maxlength=50 value="<?=$data[16];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td colspan=3>&nbsp;</td>
        </tr>
        <tr> 
         <td colspan=3 class="pHead">For SIIT student</td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>ID</td>
         <td> 
          <input type="text" name="SIITID" size=20 maxlength=50 value="<?=$data[10];?>">
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Program</td>
         <td> 
          <select name="Department">
           <option value="0" <?if(empty($data[11])){echo "SELECTED";}?>>---</option>
           <option value="BF" <?if($data[11]=="BF"){echo "SELECTED";}?>>BF</option>
           <option value="CE" <?if($data[11]=="CE"){echo "SELECTED";}?>>CE</option>
	   <option value="ChE" <?if($data[11]=="ChE"){echo "SELECTED";}?>>ChE</option>
	   <option value="CS" <?if($data[11]=="CS"){echo "SELECTED";}?>>CS</option>
           <option value="EE" <?if($data[11]=="EE"){echo "SELECTED";}?>>EE</option>
           <option value="EP" <?if($data[11]=="EP"){echo "SELECTED";}?>>EP</option>
           <option value="ET" <?if($data[11]=="ET"){echo "SELECTED";}?>>ET</option>
           <option value="EV" <?if($data[11]=="EV"){echo "SELECTED";}?>>EV</option>
           <option value="IE" <?if($data[11]=="IE"){echo "SELECTED";}?>>IE</option>
           <option value="INS" <?if($data[11]=="INS"){echo "SELECTED";}?>>INS</option>
           <option value="IT" <?if($data[11]=="IT"){echo "SELECTED";}?>>IT</option>
           <option value="ME" <?if($data[11]=="ME"){echo "SELECTED";}?>>ME</option>
           <option value="MT" <?if($data[11]=="MT"){echo "SELECTED";}?>>MT</option>
           <option value="Freshy" <?if($data[11]=="Freshy"){echo "SELECTED";}?>>Freshy</option>
          </select>
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td colspan=3>&nbsp;</td>
        </tr>
        <tr bgcolor="#FFFFEE" > 
         <td colspan=3 class="pHead">Change password</td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>New password</td>
         <td> 
          <input type="password" name="NewPassword" size=20 maxlength=50>
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>Confirm new password</td>
         <td> 
          <input type="password" name="ConfirmNewPassword" size=20 maxlength=50>
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td colspan=3>&nbsp;</td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td colspan=3 class="pHead">To change your profile, password is needed.</td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td><font color="#FF0000">*</font></td>
         <td>Password</td>
         <td> 
          <input type="password" name="EditPassword" size=20 maxlength=50>
         </td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td colspan=3>&nbsp;</td>
        </tr>
        <tr bgcolor="#FFFFEE">
         <td>&nbsp;</td>
         <td>&nbsp;</td>
         <td> 
          <input type="submit" name="Submit" value="Submit">
          <input type="reset" name="Submit2" value="Reset">
         </td>
        </tr>
       </table>
      </td>
     </tr>
    </table>
   </form>
  </td>
 </tr>
</table>

</body>
</html>
